﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace XDesigner.ORM.Test
{
    public partial class frmDataBindings : Form
    {
        public frmDataBindings()
        {
            InitializeComponent();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = Program.ORM.CreateBindingSource(
                typeof( CustomerClass ) , 
                Program.ORM.ReadAllInstances( typeof( CustomerClass )));
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            ORMBindingSource ds = (ORMBindingSource)dataGridView1.DataSource;
            if (ds != null)
            {
                MessageBox.Show( "Insert,delete or update " +  ds.Update() + " database records");
            }
        }
    }
}